/*
 * Copyright (c) 2007 jNetX.
 * http://www.jnetx.com
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * jNetX. You shall not disclose such Confidential Information and
 * shall use it only in accordance with the terms of the license
 * agreement you entered into with jNetX.
 *
 * $Id$
 */
package com.jnetx.javax.sip.address;

import junit.framework.TestCase;

import javax.sip.address.SipURI;
import java.text.ParseException;

/**
 * @author <a href="mailto:dparhonin@jnetx.ru">Dmitry Parhonin</a>
 * @version $Revision$
 */
public class SipURIParserTest extends TestCase {
    public SipURIParserTest(String name) {
        super(name);
    }

    public void testParsing() {
        SipURI uri = null;
        SipURIParser parser = new SipURIParser();
        final String uriStr = "sip:alice:secretword@atlanta.com:5061;transport=tcp;lr;custom=mine?priority=urgent&userTime=msk";
        try {
            uri = parser.parse(uriStr.getBytes(), 0, uriStr.length());
        } catch (ParseException e) {
            fail(e.getMessage());
        }
        assertEquals("The scheme is wrong!", "sip", uri.getScheme());
        assertEquals("The user name is wrong!", "alice", uri.getUser());
        assertEquals("The user password is wrong!", "secretword", uri.getUserPassword());
        assertEquals("The host is wrong!", "atlanta.com", uri.getHost());
        assertEquals("The port is wrong!", 5061, uri.getPort());
        assertEquals("The transport parameter is wrong!", "tcp", uri.getTransportParam());
        assertTrue("There should be lr parameter!", uri.hasLrParam());
        assertEquals("The custom parameter is wrong!", "mine", uri.getParameter("custom"));
        assertEquals("The custom header is wrong!", "urgent", uri.getHeader("priority"));
        assertEquals("The custom header is wrong!", "msk", uri.getHeader("userTime"));
    }
}
/*
 * $Log$
 */